<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="deviceList" checkbox="false" fitColumns="true" title="加工服务申请列表" actionUrl="processingServiceController.do?myTaskDatagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="state"  field="state.value"  hidden="true"  queryMode="single"  width="120"></t:dgCol>   
   <t:dgCol title="申请人" field="applyUser.realName" width="70" ></t:dgCol>
   <t:dgCol title="申情人手机号" field="applyCellphone" width="80" ></t:dgCol> 
   <t:dgCol title="加工名称"  field="title"   query="true" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="分配日期"  field="auditDate" formatter="yyyy-MM-dd" hidden="false"  queryMode="single"  width="100"></t:dgCol>
   <t:dgCol title="状态"  field="state.name"  hidden="false"  queryMode="single"  width="60"></t:dgCol>   
   <t:dgCol title="加工时长"  field="processingDuration"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="毛坯价格"  field="totalAmount"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="评价分数"  field="serviceScore"   queryMode="single"  width="50"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="160"></t:dgCol>
   
   <t:dgFunOpt  funname="start(id)" title="开始加工" exp="state.value#eq#2"/>
   <t:dgFunOpt  funname="buying(id)" title="毛坯采购中" exp="state.value#eq#4"/>  
   <t:dgFunOpt  funname="addProcessingInfo(id)" title="录入加工进度" exp="state.value#eq#4,5"/>
   <t:dgFunOpt  funname="viewDetail(id)" title="查看进度" exp="state.value#eq#4,5"/>
   <t:dgFunOpt  funname="finish(id)" title="完成任务" exp="state.value#eq#4,5"/>
   <t:dgFunOpt  funname="noProcess(id)" title="无法加工" exp="state.value#eq#2"/>   
   <t:dgFunOpt  funname="downloadAtta(id)" title="下载图纸" />
   
   <t:dgFunOpt  funname="showItemDetail({'查看'},{'processingServiceController.do?goUpdate'},id,{'700'},{'400'})" title="查看"  />
   
   
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">
 //查看加工明细
 function viewDetail(id){
	 var addurl = 'processingServiceController.do?showProcessingInfo&id='+id;
	  $.dialog({
		  	id:'deviceReturn',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 50, 
			width:500,
			height:400,
			title:'查看加工进度', 
			opacity : 0.3,
			ok:false,
			cache:false,
			close:true
	});	 
 }
 

function start(id){
	$.ajax({
		url:"processingServiceController.do?changeState&id="+id+"&state=4",
		success:function (data){
			data = $.parseJSON(data);
			if(data.success){
				tip("操作成功");
				reloadTable();
			}else{
				tip("操作失败！");
			}
		}
	});
}

function buying(id){
	$.ajax({
		url:"processingServiceController.do?changeState&id="+id+"&state=5",
		success:function (data){
			data = $.parseJSON(data);
			if(data.success){
				tip("操作成功");
				reloadTable();
			}else{
				tip("操作失败！");
			}
		}
	});
}

function noProcess(id){
	$.ajax({
		url:"processingServiceController.do?changeState&id="+id+"&state=7",
		success:function (data){
			data = $.parseJSON(data);
			if(data.success){
				tip("操作成功");
				reloadTable();
			}else{
				tip("操作失败！");
			}
		}
	});
}
 
 function finish(id){
	 var addurl = 'processingServiceController.do?goFinish&id='+id;
	  $.dialog({
		  	id:'deviceReturn',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 50, 
			width:420,
			height:260,
			title:'完成任务', 
			opacity : 0.3,
			ok: function(){
				iframe = this.iframe.contentWindow;
				$('#btn_sub', iframe.document).click(); 
				return false;
			},
			cache:false,
			close:reloadTable
	});
 }
 
 //录入加工进度
 function addProcessingInfo(id){
	 var addurl = 'processingServiceController.do?addProcessingInfo&id='+id;
	  $.dialog({
		  	id:'deviceReturn',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 50, 
			width:400,
			height:160,
			title:'录入加工进度', 
			opacity : 0.3,
			ok: function(){
				iframe = this.iframe.contentWindow;
				$('#btn_sub', iframe.document).click(); 
				return false;
			},
			cache:false,
			close:reloadTable
	});
 }

 

function downloadAtta(id){
	window.location.href="cms-attach.do?download&ownerId="+id;
}
 </script>